package projectsys.core.utils;

import javax.servlet.http.HttpServletRequest;

public class IPUtils {
	/**
	 * 获取客户端的IP地址
	 * @Description: 
	 * @Date: 2016年11月28日 下午3:02:45
	 * @Author whm
	 * @param rq
	 * @return
	 */
	public static String getIPAddress(HttpServletRequest rq) {
		String ip = rq.getHeader("x-forwarded-for");
		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
			ip = rq.getHeader("Proxy-Client-IP");
		}
		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
			ip = rq.getHeader("WL-Proxy-Client-IP");
		}
		if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
			ip = rq.getRemoteAddr();
		}
		return ip;
	}
}
